-
Notifications
You must be signed in to change notification settings - Fork 264
chore: Add AsyncCloseable interface. #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* Immediately closes the resource gracefully. | ||
*/ | ||
default void close() { | ||
this.closeGracefully().subscribe(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the default implementation should call block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. I think with a few tweaks it will be a useful addition.
|
||
/** | ||
* Begins the process of closing the resource gracefully, if there is one in progress, | ||
* return the existing one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's accurate? We'd need to keep track of closing-in-progress and I am not certain we do that currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you suggest we drop the :
if there is one in progress, return the existing one.
?
I think we should always return the same instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the code, you are right, not all implementation return the same Mono
, will drop this description.
Mono<Void> closeGracefully(); | ||
|
||
/** | ||
* Immediately closes the resource gracefully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The graceful close is not immediate, it kicks off asynchronously. In the cases of void
return type it is a disconnected chain.
@@ -52,6 +52,7 @@ public interface McpServerTransportProvider { | |||
* Immediately closes all the transports with connected clients and releases any | |||
* associated resources. | |||
*/ | |||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be removed.
|
||
/** | ||
* Immediately closes the resource gracefully. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An @see #closeGracfully()
javadoc entry would be useful.
Mono<Void> closeGracefully(); | ||
|
||
/** | ||
* Closes the session and releases any associated resources. | ||
*/ | ||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be removed.
@@ -45,6 +45,7 @@ public interface McpTransport { | |||
* needed. It should handle the graceful shutdown of any active connections. | |||
* </p> | |||
*/ | |||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be removed
c8a8746
to
66f6e35
Compare
Signed-off-by: He-Pin <[email protected]>
Motivation and Context
Introduce a common interface for autocloseable.
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context